package com.hatricks.is.base.memorycache;

import cn.hutool.cache.impl.TimedCache;
import cn.hutool.core.thread.ThreadUtil;

/**
 * @packageName: com.hatricks.base.memorycache
 * @className: TimeCacheUtils
 * @author: yanyh yanyh@glodon.com
 * @date: 2024/3/27 12:25
 * @description:
 */
public class TimeCacheUtils {

    public static TimedCache<String, String> TIME_CACHE = new TimedCache<>(1000L);

    public static void main(String[] args) {
        TIME_CACHE.put("zs", "ls");

        // 如果不手动启动清理线程,需要判断下 其占用缓存大小,只有过期并且get时才会清理
        ThreadUtil.safeSleep(1000);

        System.out.println(TIME_CACHE.get("zs"));
    }


}
